<template>
  <div>
    <!--走马灯 -->
    <!-- 自适应效果 -->
    <el-carousel indicator-position="outside" :autoplay="true" type="card" :interval="3000">
      <el-carousel-item v-for="item in imgLists" :key="item">
        <img :src="item" alt="item" width="400" height="300" />
      </el-carousel-item>
    </el-carousel>
    <!-- 卡片 -->
    <!-- gutter：卡片间距 -->
    <el-row :gutter="20">
      <!-- 响应式效果  xs sm md-->
      <el-col :xs="6" :sm="12" :md="6" v-for="o in cardLists" :key="o.img">
        <el-card :body-style="{ padding: '0px' }">
          <img :src="o.img">
          <div style="padding: 14px;">
            <span>{{o.title}}</span>
            <div class="bottom clearfix">
              <time class="time">{{ o.currentDate }}</time>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <div style="margin-top: 60px;">
      <el-button type="primary" @click="landingLogin">了解详情</el-button>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        imgLists: [
          require("@/views/img/cake.jpg"),
          require("@/views/img/egg.jpg"),
          require("@/views/img/milk.jpg")
        ],
        cardLists: [{
            title: '蛋糕',
            img: require("@/views/img/cake.jpg"),
            currentDate: '2023-10-19'
          },
          {
            title: '鸡蛋',
            img: require("@/views/img/egg.jpg"),
            currentDate: '2023-10-20'
          },

          {
            title: '牛奶',
            img: require("@/views/img/milk.jpg"),
            currentDate: '2022-3-22'
          },
        ],
      }
    },
    methods: {
      landingLogin(){
        this.$router.push({name: 'Login'});
      }
    }
  }
</script>

<!-- scoped的作用：不影响其他页面的样式 -->
<style scoped>
  * {
    text-align: center;
  }

  img {
    width: 50%;
    height: 200px;
    margin: auto 25%;
  }

  img:hover {
    border: 4px solid black;
  }
</style>
